package com.sbl.bajw.pc.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.sbl.bajw.common.web.JsonResultUtil;
import com.sbl.bajw.common.web.RequestUnit;
import com.sbl.bajw.pc.model.MsgBoxModel;
import com.sbl.bajw.pc.service.MsgBoxService;
import com.sbl.bajw.util.JsonUtil;

@Controller
@RequestMapping("/MsgBox")
public class MsgBoxAction {
	
	@Resource
	private MsgBoxService service;
	
	@RequestMapping(value = "/Add")
	public ModelAndView Add(){
		ModelAndView mv = new ModelAndView("/view/manager/MsgBox/main");
		return mv;
	}
	
	@RequestMapping(value = "/List")
	public ModelAndView List(){
		ModelAndView mv = new ModelAndView("/view/manager/MsgBox/List");
		return mv;
	}
	
	@RequestMapping(value = "/doAdd")
	public @ResponseBody String doAdd(){
		MsgBoxModel model = RequestUnit.getModel(MsgBoxModel.class);
		service.insert(model);
		return JsonResultUtil.Success();
	}
	
	@RequestMapping(value = "/doDelete")
	public @ResponseBody String doDelete(){
		service.delete();
		return JsonResultUtil.Success();
	}	
	
	@RequestMapping(value = "/getList")
	public @ResponseBody String getList(){
		String result = service.getList();
		return JsonResultUtil.Success(result);
	}
	
	public @ResponseBody String getDetail(){
		MsgBoxModel model = service.getDetail();
		String result = JsonUtil.ConvertObjectToJson(model);
		return JsonResultUtil.Success(result);
	}
	
	@RequestMapping(value = "/getListByUser")
	public @ResponseBody String getListByUser(){
		String result = service.getListByuser();
		return JsonResultUtil.Success(result);
	}
}
